#include <stdio.h>
int main()
{
	FILE *fp;
	int i,sum = 0,k;
	fp = fopen("f3.dat","w");
	if (NULL == fp )
	{
		perror("open");
		return 1;
	}
	for (i=0;i<10;i++)
	{
		scanf("%d",&k);
		fprintf(fp,"%d\n",k);
	}
	fclose(fp);
	fp = fopen("f3.dat","r");
	if (NULL == fp )
	{
		perror("open");
		return 1;
	}
	while(fscanf(fp,"%d",&k) != EOF)
	{
		fprintf(stdout,"%d ",k);
		sum += k ;
	}
	printf("sum = %d\n",sum);

	if(fp) fclose(fp);
	return 0;

}